package com.uy.cuantoconocesdeuruguay.server;

import java.util.List;

import android.annotation.SuppressLint;
import android.app.Activity;

import com.uy.cuantoconocesdeuruguay.controllers.ChallengeController;
import com.uy.cuantoconocesdeuruguay.controllers.ImagesController;
import com.uy.cuantoconocesdeuruguay.controllers.NotificationsController;
import com.uy.cuantoconocesdeuruguay.controllers.UsersController;
import com.uy.cuantoconocesdeuruguay.datatypes.FacebookDeviceUser;
import com.uy.cuantoconocesdeuruguay.datatypes.FriendChallengeEnvelope;
import com.uy.cuantoconocesdeuruguay.datatypes.RandomImageEnvelope;
import com.uy.cuantoconocesdeuruguay.datatypes.UploadImageEnvelope;
import com.uy.cuantoconocesdeuruguay.datatypes.UserEnvelope;
import com.uy.cuantoconocesdeuruguay.exceptions.ConnectivityException;

@SuppressLint("NewApi") 
public class ServerConnector {
	 
	//OPERATIONS WITH IMAGES IN THE MAIN GAME
	public static RandomImageEnvelope getNextImage(String lastImageId) throws ConnectivityException {
		return ImagesController.getNextImage(lastImageId);
	}	
	public static void incrementScore(int score, int imageID, boolean isImage) throws ConnectivityException {
		ImagesController.incrementScore(score, imageID, isImage);
	} 
	public static void useHint(int imageID, long timeIncremented) throws ConnectivityException  {
		ImagesController.useHint(imageID, timeIncremented);
	}
	public static void useBomb(int imageID, long timeIncremented) throws ConnectivityException  {
		ImagesController.useBomb(imageID, timeIncremented);
	}
	public static void skipImage(int imageID) throws ConnectivityException  {
		ImagesController.skipImage(imageID);
	} 
	
	//OPERATIONS WITH CHALLENGES
	public static RandomImageEnvelope getChallengeImage(String imageId) throws ConnectivityException {
		return ChallengeController.getChallengeImage(imageId);
	}
	public static void challengeFriend(String friendId) throws ConnectivityException  {
		ChallengeController.challengeFriend(friendId);
	}
	public static void acceptChallenge(String challengeId, String oponentFacebookId) throws ConnectivityException  {
		ChallengeController.acceptChallenge(challengeId, oponentFacebookId);
	}
	public static void setChallengeStartTime(String challengeId) throws ConnectivityException  {
		ChallengeController.setChallengeStartTime(challengeId);		
	}
	public static List<FriendChallengeEnvelope> getMyChallenges() throws ConnectivityException  {
		return ChallengeController.getMyChallenges();
	}
	public static FriendChallengeEnvelope getChallenge(String id) throws ConnectivityException  {
		return ChallengeController.getChallenge(id);
	}	
	public static FriendChallengeEnvelope incrementChallengeScore(int score, int imageID, boolean proposer, FriendChallengeEnvelope challenge, String friendId) throws ConnectivityException {
		return ChallengeController.incrementChallengeScore(score, imageID, proposer, challenge, friendId);
	}
	public static void setChallengeFinished(String challengeId) throws ConnectivityException{
		ChallengeController.setChallengeFinished(challengeId);
	}
	public static void deleteChallenge(String challengeId, boolean proposer) throws ConnectivityException{
		ChallengeController.deleteChallenge(challengeId, proposer);
	}

	//OPERATIONS WITH USERS
	public static void facebookLogin(String facebookid) throws ConnectivityException  {
		UsersController.facebookLogin(facebookid);
	}
	public static UserEnvelope getUserData() throws ConnectivityException {
		return UsersController.getUserData();
	}
	public static List<FacebookDeviceUser> getFriendsScores(String listOfFriendsIds) throws ConnectivityException  {
		return UsersController.getFriendsScores(listOfFriendsIds);
	}	
	public static FacebookDeviceUser getFriendScore(String friendId) throws ConnectivityException {
		return UsersController.getFriendScore(friendId);
	}
	
	//NOTIFICATIONS OPERATIONS
	public static void setGoogleGCMRegId(String regId) throws ConnectivityException {
		NotificationsController.setGoogleGCMRegId(regId);
	}
	
	//UPLOAD OPERATIONS
	public static void submitPicture( UploadImageEnvelope envelope, Activity activity) throws ConnectivityException  {
		ImagesController.submitPicture(envelope, activity);
	}
}
